/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View.ventas;

import Model.Producto;
import Presenter.EnvioPedidoPresenter;
import Presenter.ProductoPresenter;
import View.components.Index;
import java.math.BigDecimal;
import javax.swing.JDesktopPane;
import javax.swing.JOptionPane;
import Principals.Validadores;

/**
 *
 * @author Paola
 */
public class Frm_ModificarProducto extends javax.swing.JDesktopPane {

    Validadores val = new Validadores();

    /**
     * Creates new form Frm_ModificarProducto
     */
    public Frm_ModificarProducto(int idCliente) {

        Producto p = ProductoPresenter.cargarProducto(idCliente);
        initComponents();
        val.desactivarAccionPegar(txtNombre);
        val.desactivarAccionPegar(txtPrecioCosto);
        val.desactivarAccionPegar(txtPrecioLista);
        val.desactivarAccionPegar(txtStock);         
        EnvioPedidoPresenter.actualizarEnvioPedido() ; 
        txtIdProducto.setText(Integer.toString(p.getIdProducto()));
        txtNombre.setText(p.getNombre());
        txtPrecioCosto.setText(p.getPrecioCosto().toString());
        txtPrecioLista.setText(p.getPrecioLista().toString());
        txtStock.setText(Integer.toString(p.getStock()));
        switch (p.getEstado()) {
            case 0:
                cbxEstado.setSelectedIndex(0);
                break;
            case 1:
                cbxEstado.setSelectedIndex(1);
                break;
        }        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlModificarProducto = new javax.swing.JPanel();
        lblNombre = new javax.swing.JLabel();
        lblPrecioCosto = new javax.swing.JLabel();
        lblPrecioLista = new javax.swing.JLabel();
        txtNombre = new javax.swing.JTextField();
        lblStock = new javax.swing.JLabel();
        txtPrecioCosto = new javax.swing.JTextField();
        txtPrecioLista = new javax.swing.JTextField();
        txtStock = new javax.swing.JTextField();
        txtIdProducto = new javax.swing.JTextField();
        lblIdProducto = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        lblEstado = new javax.swing.JLabel();
        cbxEstado = new javax.swing.JComboBox();
        jToolBar1 = new javax.swing.JToolBar();
        btnToolNuevo = new javax.swing.JButton();
        btnToolModificar = new javax.swing.JButton();
        btnToolGuardar = new javax.swing.JButton();
        btnToolEliminar = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JToolBar.Separator();
        btnToolLimpiar = new javax.swing.JButton();
        btnToolBuscar = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        btnToolCancelar = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JToolBar.Separator();

        pnlModificarProducto.setBorder(javax.swing.BorderFactory.createTitledBorder("Modificar Registro"));

        lblNombre.setText("Nombre*:");

        lblPrecioCosto.setText("Precio Costo*:");

        lblPrecioLista.setText("Precio Lista*:");

        txtNombre.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtNombreKeyTyped(evt);
            }
        });

        lblStock.setText("Stock*:");

        txtPrecioCosto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtPrecioCostoKeyTyped(evt);
            }
        });

        txtPrecioLista.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtPrecioListaKeyTyped(evt);
            }
        });

        txtStock.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtStockKeyTyped(evt);
            }
        });

        txtIdProducto.setEnabled(false);
        txtIdProducto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtIdProductoActionPerformed(evt);
            }
        });

        lblIdProducto.setText("Id Producto");

        jLabel2.setText("S/.");

        jLabel3.setText("S/.");

        lblEstado.setText("Estado:");

        cbxEstado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Inactivo", "Activo" }));
        cbxEstado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbxEstadoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnlModificarProductoLayout = new javax.swing.GroupLayout(pnlModificarProducto);
        pnlModificarProducto.setLayout(pnlModificarProductoLayout);
        pnlModificarProductoLayout.setHorizontalGroup(
            pnlModificarProductoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlModificarProductoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlModificarProductoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblStock)
                    .addComponent(lblNombre)
                    .addComponent(lblPrecioCosto)
                    .addComponent(lblPrecioLista)
                    .addComponent(lblIdProducto))
                .addGap(18, 18, 18)
                .addGroup(pnlModificarProductoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlModificarProductoLayout.createSequentialGroup()
                        .addGroup(pnlModificarProductoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(txtStock, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE)
                            .addComponent(txtPrecioLista, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtPrecioCosto, javax.swing.GroupLayout.Alignment.LEADING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlModificarProductoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3)))
                    .addGroup(pnlModificarProductoLayout.createSequentialGroup()
                        .addGroup(pnlModificarProductoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pnlModificarProductoLayout.createSequentialGroup()
                                .addComponent(txtIdProducto, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(lblEstado))
                            .addComponent(txtNombre, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(cbxEstado, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(22, Short.MAX_VALUE))
        );
        pnlModificarProductoLayout.setVerticalGroup(
            pnlModificarProductoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlModificarProductoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlModificarProductoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtIdProducto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblIdProducto)
                    .addComponent(lblEstado)
                    .addComponent(cbxEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlModificarProductoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblNombre, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlModificarProductoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPrecioCosto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblPrecioCosto)
                    .addComponent(jLabel2))
                .addGap(18, 18, 18)
                .addGroup(pnlModificarProductoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtPrecioLista, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblPrecioLista)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnlModificarProductoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblStock)
                    .addComponent(txtStock, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(47, Short.MAX_VALUE))
        );

        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);
        jToolBar1.setBorderPainted(false);
        jToolBar1.addContainerListener(new java.awt.event.ContainerAdapter() {
            public void componentAdded(java.awt.event.ContainerEvent evt) {
                jToolBar1ComponentAdded(evt);
            }
        });

        btnToolNuevo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Nuevo.png"))); // NOI18N
        btnToolNuevo.setEnabled(false);
        btnToolNuevo.setFocusable(false);
        btnToolNuevo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolNuevo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolNuevoActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolNuevo);

        btnToolModificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Editar.png"))); // NOI18N
        btnToolModificar.setEnabled(false);
        btnToolModificar.setFocusable(false);
        btnToolModificar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolModificar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolModificarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolModificar);

        btnToolGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Guardar.png"))); // NOI18N
        btnToolGuardar.setFocusable(false);
        btnToolGuardar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolGuardar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolGuardarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolGuardar);

        btnToolEliminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Eliminar.png"))); // NOI18N
        btnToolEliminar.setEnabled(false);
        btnToolEliminar.setFocusable(false);
        btnToolEliminar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolEliminar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolEliminarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolEliminar);
        jToolBar1.add(jSeparator2);

        btnToolLimpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Limpiar.png"))); // NOI18N
        btnToolLimpiar.setEnabled(false);
        btnToolLimpiar.setFocusable(false);
        btnToolLimpiar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolLimpiar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolLimpiarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolLimpiar);

        btnToolBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Buscar.png"))); // NOI18N
        btnToolBuscar.setFocusable(false);
        btnToolBuscar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolBuscar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolBuscarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolBuscar);
        jToolBar1.add(jSeparator1);

        btnToolCancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/botones/Cancelar.png"))); // NOI18N
        btnToolCancelar.setFocusable(false);
        btnToolCancelar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnToolCancelar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnToolCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnToolCancelarActionPerformed(evt);
            }
        });
        jToolBar1.add(btnToolCancelar);
        jToolBar1.add(jSeparator3);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pnlModificarProducto, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 410, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnlModificarProducto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void cambiarVista(JDesktopPane panel) {
        ((Index) (this.getTopLevelAncestor())).changeDesktopPane(panel);
    }
    private void btnToolNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolNuevoActionPerformed
    }//GEN-LAST:event_btnToolNuevoActionPerformed

    private void btnToolModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolModificarActionPerformed
    }//GEN-LAST:event_btnToolModificarActionPerformed

    private void btnToolLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolLimpiarActionPerformed
    }//GEN-LAST:event_btnToolLimpiarActionPerformed

    private void btnToolBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolBuscarActionPerformed
        cambiarVista(new Frm_BuscarProducto());
    }//GEN-LAST:event_btnToolBuscarActionPerformed

    private void btnToolCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolCancelarActionPerformed
        cambiarVista(new Frm_BuscarProducto()); // si se cancela se va a buscar
    }//GEN-LAST:event_btnToolCancelarActionPerformed

    private void btnToolEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolEliminarActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnToolEliminarActionPerformed

    private void jToolBar1ComponentAdded(java.awt.event.ContainerEvent evt) {//GEN-FIRST:event_jToolBar1ComponentAdded
        // TODO add your handling code here:
    }//GEN-LAST:event_jToolBar1ComponentAdded

    private void txtIdProductoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtIdProductoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtIdProductoActionPerformed

    private void btnToolGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnToolGuardarActionPerformed
        
            try {
                String nombre = txtNombre.getText();
                String pc = txtPrecioCosto.getText();
                String pl = txtPrecioLista.getText();
                String s = txtStock.getText();
                BigDecimal precioCosto = new BigDecimal(0);
                BigDecimal precioLista = new BigDecimal(0);
                int stock = 0;
                int estado= cbxEstado.getSelectedIndex();
                String msj_error = "";
                boolean error = false;
                boolean pc_val=false;
                boolean pl_val=false;
                
                if (nombre.isEmpty() || pc.isEmpty() || pl.isEmpty() || s.isEmpty()) {
                    msj_error = "Debe ingresar todos los campos obligatorios.";
                    error = true;
                    //JOptionPane.showMessageDialog(this, "Por favor ingresar todos los campos");
                }
            if (!nombre.isEmpty() && nombre.length() > 20) {
                if (error) {
                    msj_error = msj_error.concat("\n");
                }
                msj_error = msj_error.concat("El campo Nombre debe ser máximo de 20 caracteres.");
                error = true;
            }                 
                if (!pc.isEmpty()) {
                    
                    if(val.validaOcurrencias('.', txtPrecioCosto.getText()) > 1){
                        if (error) {
                            msj_error = msj_error.concat("\n");
                        }
                        msj_error = msj_error.concat("Debe ingresar un Precio de Costo válido .");
                        error = true;
                    }
                    else if (new BigDecimal(txtPrecioCosto.getText()).compareTo(new BigDecimal(999999.99)) == 1){  
                        if (error) {
                            msj_error = msj_error.concat("\n");
                        }
                        msj_error = msj_error.concat("Debe ingresar un Precio de Costo menor a 9999999.99 .");
                        error = true;   
                         
                    }
                    else{
                        pc_val=true;
                        precioCosto = new BigDecimal(txtPrecioCosto.getText());
                    }
                }
                
                if (!pl.isEmpty()) {
                    
                    if(val.validaOcurrencias('.', txtPrecioLista.getText()) > 1){        
                        if (error) {
                            msj_error = msj_error.concat("\n");
                        }
                        msj_error = msj_error.concat("Debe ingresar un Precio de Lista válido .");
                        error = true;
                    }
                    else if (new BigDecimal(txtPrecioLista.getText()).compareTo(new BigDecimal(999999.99)) == 1){  
                        if (error) {
                            msj_error = msj_error.concat("\n");
                        }
                        msj_error = msj_error.concat("Debe ingresar un Precio de Lista menor a 9999999.99 .");
                        error = true;   
                         
                    }
                    else{
                        precioLista = new BigDecimal(txtPrecioLista.getText());
                        pl_val=true;
                    }
                }

                if (!pc.isEmpty() && !pl.isEmpty() && pc_val && pl_val && precioCosto.compareTo(precioLista) == 1) {
                    if (error) {
                        msj_error = msj_error.concat("\n");
                    }
                    msj_error = msj_error.concat("Debe ingresar un Precio de Lista mayor al Precio de Costo.");
                    error = true;
                }
                if (!s.isEmpty() && (stock=Integer.parseInt(txtStock.getText())) == 0) {
                    if (error) {
                        msj_error = msj_error.concat("\n");
                    }
                    msj_error = msj_error.concat("El Stock debe ser mayor que cero.");
                    error = true;
                }  
                
                if (error) {
                    JOptionPane.showMessageDialog(this, msj_error);
                } else {
                    int idProducto = Integer.parseInt(txtIdProducto.getText());
                    int respuesta = JOptionPane.showConfirmDialog(this, "Desea guardar los cambios", "Modificar", JOptionPane.OK_CANCEL_OPTION);
                    switch (respuesta) {
                        case JOptionPane.OK_OPTION:
                            ProductoPresenter.modificarProducto(idProducto, nombre, precioCosto, precioLista, stock,estado);
                            JOptionPane.showMessageDialog(this, "Se guardaron los cambios.");
                            cambiarVista(new Frm_BuscarProducto());
                            break;
                        case JOptionPane.CANCEL_OPTION:
                            break;
                    }
                    //cambiarVista(new Frm_BuscarProducto());
                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(this, "No se pudo realizar la transacción.");
                System.out.println("MENSAJE DE ERROR:" + e);
            }
    }//GEN-LAST:event_btnToolGuardarActionPerformed

    private void txtNombreKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNombreKeyTyped
        val.validaCaracteresRaros(evt);
        val.validaMaxSize(evt, 20, txtNombre.getText());
        txtNombre.setTransferHandler(null);
    }//GEN-LAST:event_txtNombreKeyTyped

    private void txtPrecioCostoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPrecioCostoKeyTyped
        val.validaDoublePositivo(evt);
        val.validaMaxSize(evt, 9, txtPrecioCosto.getText());
        txtPrecioCosto.setTransferHandler(null);
    }//GEN-LAST:event_txtPrecioCostoKeyTyped

    private void txtPrecioListaKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPrecioListaKeyTyped
        val.validaDoublePositivo(evt);
        val.validaMaxSize(evt, 9, txtPrecioLista.getText());
        txtPrecioLista.setTransferHandler(null);
    }//GEN-LAST:event_txtPrecioListaKeyTyped

    private void txtStockKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtStockKeyTyped
        val.validaSoloNumeros(evt);
        val.validaMaxSize(evt, 7, txtStock.getText());
        txtStock.setTransferHandler(null);
    }//GEN-LAST:event_txtStockKeyTyped

    private void cbxEstadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbxEstadoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cbxEstadoActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnToolBuscar;
    private javax.swing.JButton btnToolCancelar;
    private javax.swing.JButton btnToolEliminar;
    private javax.swing.JButton btnToolGuardar;
    private javax.swing.JButton btnToolLimpiar;
    private javax.swing.JButton btnToolModificar;
    private javax.swing.JButton btnToolNuevo;
    private javax.swing.JComboBox cbxEstado;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar.Separator jSeparator2;
    private javax.swing.JToolBar.Separator jSeparator3;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JLabel lblEstado;
    private javax.swing.JLabel lblIdProducto;
    private javax.swing.JLabel lblNombre;
    private javax.swing.JLabel lblPrecioCosto;
    private javax.swing.JLabel lblPrecioLista;
    private javax.swing.JLabel lblStock;
    private javax.swing.JPanel pnlModificarProducto;
    private javax.swing.JTextField txtIdProducto;
    private javax.swing.JTextField txtNombre;
    private javax.swing.JTextField txtPrecioCosto;
    private javax.swing.JTextField txtPrecioLista;
    private javax.swing.JTextField txtStock;
    // End of variables declaration//GEN-END:variables
}
